﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Infrastructure;
using Models;
using IService;
using ConcreteService;
using RepositoryMSSQL;
using IRepository;
using System.Web.Script.Serialization;
using System.Text;
using System.Text.RegularExpressions;

namespace WebSite.Controllers
{
    [HandleError]
    public class HomeController : Controller
    {
        public ActionResult Index()
        {
            ViewData["Message"] = "Welcome to ASP.NET MVC!";

            return View();
        }

        public ActionResult About()
        {
            ITaskService service = FactoryCreator.Create<IServiceFactory>().Create<ITaskService>();
            TaskInfo info = new TaskInfo();
            info.Creator = "xiaoboli";
            info.Name = "task 1";
            info.StartDate = DateTime.Now;
            info.EndDate = DateTime.Now.AddDays(1);
            info.Remark = "remark1";
            service.CreateTask(info);
            ViewData["TicketInfo"] = info.Code;
            return View();
        }

        public ActionResult Chat()
        {
            return View();
        }

        public string GetData()
        {
            IExecuteRecordService service = FactoryCreator.Create<IExecuteRecordService>();
            List<ExecuteRecord> lst = service.ListRecord();

            return new JavaScriptSerializer().Serialize(lst);
        }
    }
}
